﻿using System;

namespace MikeKappel.Com.Uploader
{
    internal enum uploadStatus
    {
        Waiting,
        Working,
        Completed
    }
    internal class UploaderInfo
    {
        public Guid ID { get; private set; }
        public String Name { get; set; }
        public String ClientID { get; private set; }
        public Int32 Width { get; set; }
        public Int32 Height { get; set; }
        public String[] MimesExcepted { get; set; }
        public Int32? MaxSize { get; set; }
        public String CssUrlInner { get; set; }
        public String TextForImageChange { get; set; }
        public String TextForOversize { get; set; }
        public String TextForUnsupported { get; set; }
        public String TextForCancelled { get; set; } 
        public uploadStatus Status { get; set; }
        public Int32? Progress {
            get
            {
                return _progress;
            }
            set
            {
                _progress = value;
                if (!_progress.HasValue && Status != uploadStatus.Waiting)
                    Status = uploadStatus.Waiting;
                else if (_progress.HasValue && _progress.Value == 100 && Status != uploadStatus.Completed)
                    Status = uploadStatus.Completed;
                else if (_progress.HasValue && _progress.Value != 100 && Status != uploadStatus.Working)
                {
                    Status = uploadStatus.Working;
                    Content = null;
                }
            }
        }
        private Int32? _progress;
        public Byte[] Content { get; set; }
        public String Mime { get; set; }
        public UploaderEventArgs.UploadComplete OnUploadComplete { get; set; }
        public UploaderInfo(Guid id, String name)
        {
            ID = id;
            ClientID = name;
            Name = name;
        }
    }
}
